CC = sdcc
CFLAGS= --std-c99 -c -mpic16 -p18f97j60 -D__SDCC__ -D__18F97J60 $(INCLUDE_PATHS)

LD = sdcc
LDFLAGS= -mpic16 -p18f97j60 -L/usr/share/sdcc/non-free/lib/pic16 -L/usr/local/share/sdcc/non-free/lib/pic16 -L/usr/share/sdcc/lib/pic16 -L/usr/local/share/sdcc/lib/pic16 \
	-llibio18f97j60.lib -llibdev18f97j60.lib -llibc18f.lib

INCLUDE_PATHS = -I../Include -I./ -I/usr/share/sdcc/include -I/usr/local/share/sdcc/include -I/usr/share/sdcc/non-free/include/pic16 -I/usr/local/share/sdcc/non-free/include/pic16

all: LCDBlocking.o main.o
	$(LD) $(LDFLAGS) build/main.o build/LCDBlocking.o -o build/main.hex
	cp build/main.hex .

main.o: main.c build
	$(CC) $(CFLAGS) main.c -o build/main.o

LCDBlocking.o: ../TCPIP_Stack/LCDBlocking.c build
	$(CC) $(CFLAGS) ../TCPIP_Stack/LCDBlocking.c -o build/LCDBlocking.o

build:
	mkdir build

clean : 
	rm -rf build
	rm main.hex
